from celery_tasks.yuntongxun.sms import CCP
from celery_tasks.main import celery_app
import logging

logger = logging.getLogger("django")

@celery_app.task(name="celery: send_sms_code")
def send_sms_code(mobile, sms_code, message_expires, message_model):
    try:
        result = CCP().send_template_sms(mobile, [sms_code, message_expires], message_model)
    except Exception as e:
        logger.error("发送短信异常 %s, 错误信息%s" % (mobile,str(e)))
    else:
        if result==0:
            logger.info("发送短信成功 %s" % mobile)
        else:
            logger.warning("第三方工具发送短信失败 %s" % mobile)
